//
//  RightCollectionViewCell.m
//  GentlemanAnime
//
//  Created by dlios on 15-7-6.
//  Copyright (c) 2015年 lanou3g.com 蓝欧科技. All rights reserved.
//

#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

#import "RightCollectionViewCell.h"
#import "AppDelegate.h"

@implementation RightCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        UIView *aView = [[UIView alloc] initWithFrame:CGRectMake(70, 90 * HEIGHT / 480, WIDTH - 90, 1)];
        aView.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:aView];
        [aView release];
        
        UIView *bView = [[UIView alloc] initWithFrame:CGRectMake(WIDTH - 30, 90 * HEIGHT / 480 - 10, 1, HEIGHT / 2)];
        bView.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:bView];
        [bView release];
        
        UIView *cView = [[UIView alloc] initWithFrame:CGRectMake(20, 90 * HEIGHT / 480 + HEIGHT / 2 + 70, WIDTH - 70, 1)];
        cView.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:cView];
        [cView release];
        
        UIView *dView = [[UIView alloc] initWithFrame:CGRectMake(30, 90 * HEIGHT / 480 + 80, 1, HEIGHT / 2)];
        dView.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:dView];
        [dView release];
        
        
        UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        backButton.frame = CGRectMake(WIDTH - 40, 90 * HEIGHT / 480, 60, 30);
        backButton.center = CGPointMake(dView.frame.origin.x + 5, aView.frame.origin.y);
        [backButton setTitle:@"返回" forState:UIControlStateNormal];
        backButton.imageEdgeInsets = UIEdgeInsetsMake(5, 0, 5, 40);
        [backButton setImage:[UIImage imageNamed:@"单箭头"] forState:UIControlStateNormal];
        backButton.titleLabel.font = [UIFont systemFontOfSize:16];
        backButton.titleEdgeInsets = UIEdgeInsetsMake(0, - 20, 0, 0);
        backButton.titleLabel.textAlignment = NSTextAlignmentCenter;
        backButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        
        [backButton addTarget:self action:@selector(backButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:backButton];
        
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH / 3, WIDTH / 3)];
        imageView.center = CGPointMake(WIDTH / 2, 90 * HEIGHT / 480 + imageView.frame.size.height / 2 + 30);
        imageView.layer.cornerRadius = 15;
        imageView.clipsToBounds = YES;
        imageView.image = [UIImage imageNamed:@"logo300*300"];
        [self.contentView addSubview:imageView];
        [imageView release];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, WIDTH / 2, WIDTH / 6)];
        label.center = CGPointMake(WIDTH / 2 + 5,imageView.frame.origin.y + imageView.frame.size.height + label.frame.size.height / 2 + 20 * WIDTH / 320);
        label.font = [UIFont systemFontOfSize:15];
        label.textColor = [UIColor grayColor];
        label.textAlignment = NSTextAlignmentCenter;
        label.numberOfLines = 0;
        label.text = @"多多收藏,迎接不一样的麻吉";
        [self.contentView addSubview:label];
        [label release];
        
        UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH * 2 / 3, 30)];
        backView.center = CGPointMake(WIDTH / 2, cView.frame.origin.y - 25);
        backView.layer.cornerRadius = 8;
        backView.clipsToBounds = YES;
//        backView.backgroundColor = [UIColor colorWithWhite:1.000 alpha:0.200];
        [self.contentView addSubview:backView];
        [backView release];
        
        UILabel *lianxiLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, WIDTH * 2 / 3, 15)];
        lianxiLabel.textColor = [UIColor grayColor];
        lianxiLabel.text = @"意见反馈邮箱:";
        lianxiLabel.textAlignment = NSTextAlignmentCenter;
        lianxiLabel.font = [UIFont systemFontOfSize:12];
        [backView addSubview:lianxiLabel];
        [lianxiLabel release];
        
        UILabel *emilLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 15, WIDTH * 2 / 3, 15)];
        emilLabel.textColor = [UIColor grayColor];
        emilLabel.text = @"jiangshiqi2013@163.com";
        emilLabel.font = [UIFont systemFontOfSize:12];
        emilLabel.textAlignment = NSTextAlignmentCenter;
        [backView addSubview:emilLabel];
        [emilLabel release];
    }
    return self;
}

- (void)backButtonClick:(UIButton *)button {
    AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    [tempAppDelegate.homeVC.collectionView setContentOffset:CGPointMake(0, 0)animated:YES];
}

@end
